package com.shanyu.curd.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shanyu.curd.dao.IBaseDao;
import com.shanyu.mapper.IBaseMapper;

@Repository
public class BaseDaoImpl<T> implements IBaseDao<T>{
	@Autowired
	private IBaseMapper<T> baseMapper;

	public int insert(T record) {
		// TODO Auto-generated method stub
		return baseMapper.insert(record);
	}

	public int insertSelective(T record){
		return baseMapper.insertSelective(record);
	}

	public int updateById(T record) {
		// TODO Auto-generated method stub
		return baseMapper.update(record);
	}
	
	public int updateSelective(T record){
		return baseMapper.updateSelective(record);
	}

	public T selectOne(T entity) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<T> select(T entity) {
		// TODO Auto-generated method stub
		return baseMapper.selectList(entity);
	}

	public PageInfo page(T entity, int pageNum, int pageSize) {
		// TODO Auto-generated method stub
		PageHelper.startPage(pageNum, pageSize);
		PageInfo page =new PageInfo(baseMapper.selectList(entity));
		return page;
	}

	public T getById(String id) {
		// TODO Auto-generated method stub
		return baseMapper.selectByPrimaryKey(id);
	}

	public List<T> getAll() {
		// TODO Auto-generated method stub
		return null;
	}

	public int count(T entity) {
		// TODO Auto-generated method stub
		return 0;
	}

	public int delete(T entity) {
		// TODO Auto-generated method stub
		return baseMapper.delete(entity);
	}

	public int deleteByPrimary(String primary) {
		// TODO Auto-generated method stub
		return baseMapper.deleteById(primary);
	}

	public int clear() {
		// TODO Auto-generated method stub
		return 0;
	}

	public List<T> findAllList() {
		// TODO Auto-generated method stub
		return null;
	}

	
	
}
